package com.cskaoyan.service;

import com.cskaoyan.bean.vo.RowsGoodsVO;
import com.cskaoyan.bean.vo.RowsOrderVO;
import com.cskaoyan.bean.vo.RowsUserVO;
import com.cskaoyan.bean.vo.StatVO;
import com.cskaoyan.mapper.MarketUserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @author : qj
 * @since: 2022/10/12  20:15
 */
@Service
public class AdminStatServiceImpl implements AdminStatService {

    @Autowired
    MarketUserMapper marketUserMapper;

    /**
     * 统计用户
     * @return com.cskaoyan.bean.vo.StatVO 
     * @author qj
     * @since 2022/10/13 11:26
     */
    @Override
    public StatVO statUser() {
        List<String> columns = new ArrayList<>();
        columns.add("day");
        columns.add("users");
        StatVO statUserVO = new StatVO();
        statUserVO.setColumns(columns);
        List<RowsUserVO> rows = marketUserMapper.statUserByDay();
        statUserVO.setRows(rows);
        return statUserVO;
    }

    /**
     * 统计订单
     * @return com.cskaoyan.bean.vo.StatVO
     * @author qj
     * @since 2022/10/13 11:27
     */
    @Override
    public StatVO statOrder() {
        List<String> columns = new ArrayList<>();
        columns.add("day");
        columns.add("orders");
        columns.add("customers");
        columns.add("amount");
        columns.add("pcr");
        StatVO statOrderVO = new StatVO();
        statOrderVO.setColumns(columns);
        List<RowsOrderVO> rows = marketUserMapper.statOrderByDay();
        statOrderVO.setRows(rows);
        return statOrderVO;
    }
    /**
     * 统计订单商品
     * @return com.cskaoyan.bean.vo.StatVO
     * @author qj
     * @since 2022/10/13 11:28
     */
    @Override
    public StatVO statGoods() {
        List<String> columns = new ArrayList<>();
        columns.add("day");
        columns.add("orders");
        columns.add("products");
        columns.add("amount");
        StatVO statGoodsVO = new StatVO();
        statGoodsVO.setColumns(columns);
        List<RowsGoodsVO> rows = marketUserMapper.statGoodsByDay();
        statGoodsVO.setRows(rows);
        return statGoodsVO;
    }
}
